package com.ruoyi.project.paea.signaturelog.controller;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.paea.signaturelog.domain.PaeaParaRizedSignatureLog;
import com.ruoyi.project.paea.signaturelog.service.IPaeaParaRizedSignatureLogService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import java.util.Arrays;

import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 有权人操作日志Controller
 *
 * @author gang.wei
 * @date 2020-05-01
 */
@Controller
@RequestMapping("/paea/signaturelog")
public class PaeaParaRizedSignatureLogController extends BaseController
{
    private String prefix = "paea/signaturelog";

    @Autowired
    private IPaeaParaRizedSignatureLogService paeaParaRizedSignatureLogService;

    @RequiresPermissions("paea:signaturelog:view")
    @GetMapping()
    public String signaturelog()
    {
        return prefix + "/signaturelog";
    }

    /**
     * 查询有权人操作日志列表
     */
    @RequiresPermissions("paea:signaturelog:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PaeaParaRizedSignatureLog paeaParaRizedSignatureLog)
    {
        startPage();
        List<PaeaParaRizedSignatureLog> list = paeaParaRizedSignatureLogService.list(new QueryWrapper<>(paeaParaRizedSignatureLog));
        return getDataTable(list);
    }
    /**
     * 查询权人操作日志列表
     */
    @RequiresPermissions("oms:paeaRiskItem:querySignaturelogsBySignatureId")
    @PostMapping("/querySignaturelogsBySignatureId")
    @ResponseBody
    public TableDataInfo querySignaturelogsBySignatureId(String signatureId)
    {
        startPage();
        List<PaeaParaRizedSignatureLog> list = paeaParaRizedSignatureLogService.querySignaturelogsBySignatureId(signatureId);
        return getDataTable(list);
    }
    /**
     * 导出有权人操作日志列表
     */
    @RequiresPermissions("paea:signaturelog:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PaeaParaRizedSignatureLog paeaParaRizedSignatureLog)
    {
        List<PaeaParaRizedSignatureLog> list = paeaParaRizedSignatureLogService.list(new QueryWrapper<>(paeaParaRizedSignatureLog));
        ExcelUtil<PaeaParaRizedSignatureLog> util = new ExcelUtil<PaeaParaRizedSignatureLog>(PaeaParaRizedSignatureLog.class);
        return util.exportExcel(list, "signaturelog");
    }

    /**
     * 新增有权人操作日志
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存有权人操作日志
     */
    @RequiresPermissions("paea:signaturelog:add")
    @Log(title = "有权人操作日志", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PaeaParaRizedSignatureLog paeaParaRizedSignatureLog)
    {
        return toAjax(paeaParaRizedSignatureLogService.saveOrUpdate(paeaParaRizedSignatureLog));
    }

    /**
     * 修改有权人操作日志
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        PaeaParaRizedSignatureLog paeaParaRizedSignatureLog = paeaParaRizedSignatureLogService.getById(id);
        mmap.put("paeaParaRizedSignatureLog", paeaParaRizedSignatureLog);
        return prefix + "/edit";
    }

    /**
     * 修改保存有权人操作日志
     */
    @RequiresPermissions("paea:signaturelog:edit")
    @Log(title = "有权人操作日志", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PaeaParaRizedSignatureLog paeaParaRizedSignatureLog)
    {
        return toAjax(paeaParaRizedSignatureLogService.saveOrUpdate(paeaParaRizedSignatureLog));
    }

    /**
     * 删除有权人操作日志
     */
    @RequiresPermissions("paea:signaturelog:remove")
    @Log(title = "有权人操作日志", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(paeaParaRizedSignatureLogService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
